<?php

namespace app\common\lib;
class ClassArr
{
    public static function smsClassStat()
    {
        return [
            "ali" => "app\common\lib\sms\Alisms",
            "qq" => "app\common\lib\sms\Qqsms",
            "baidu" => "app\common\lib\sms\Baidusms",
        ];
    }

    public static function initClass($type, $classs, $params = [], $needInstance = false)
    {
        // 如果我们工厂模式 返回的方法是静态的 返回类库即可
        //如果不是 返回obj
        if (!array_key_exists($type, $classs)) {
            return false;
        }
        $className = $classs[$type];
        // new ReflectionClass("A")  建立反射类
        // newInstanceArgs($args)
        return $needInstance == true ? (new \ReflectionClass($className))->newInstanceArgs($params) : $className;
    }
}